<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ViewHouseRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'   => 'required|string',
            'tel' => 'required|regex:/^1[3456789][0-9]{9}$/',
            'captcha' => 'required|captcha',
            'verify' => 'required'
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '称呼一定要填哦',
            'tel.required' => '手机号一定要填哦',
            'tel.regex' => '手机号格式错误',
            'captcha.required' => '验证码一定要填哦',
            'captcha.captcha' => '验证码错误',
            'verify.required' => '短信验证码一定要填哦',
        ];
    }
}
